package com.example.mainstream.adapter;

import android.view.View;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.viewholder.BaseViewHolder;
import com.example.shopapp.R;
import com.example.shopapp.bean.ShopAddress;

/**
 * 文件名：HarvestAddressAdapter
 * 作  者： admin
 * 描述：收获地址适配器
 */
public class HarvestAddressAdapter extends BaseQuickAdapter<ShopAddress, BaseViewHolder> {

    private OnAddressListener listener;

    public HarvestAddressAdapter(OnAddressListener listener) {
        super(R.layout.item_address);
        this.listener = listener;
    }

    @Override
    protected void convert(BaseViewHolder helper, ShopAddress item) {
        if ("0".equals(item.getDefaultcity())){//是否是默认地址
            helper.getView(R.id.tv_default).setVisibility(View.VISIBLE);
        }else {
            helper.getView(R.id.tv_default).setVisibility(View.GONE);
        }
        helper.setText(R.id.tv_name,item.getUser());
        helper.setText(R.id.tv_mobile,item.getMobile());
        helper.setText(R.id.tv_address,item.getAddress());
        helper.setText(R.id.tv_city,item.getCity());
        helper.getView(R.id.rl_address).setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                if (listener != null){
                    listener.onAddressClick(item);
                }
            }
        });
    }
}
